home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 10 / AACD 10.iso / AACD / Games / MAME / src / vidhrdw / solomon.c < prev    next >
C/C++ Source or Header  |  2000-04-04  |  4KB  |  203 lines

  1. #include "driver.h"
  2. #include "vidhrdw/generic.h"
  3.  
  4.  
  5. unsigned char *solomon_bgvideoram;
  6. unsigned char *solomon_bgcolorram;
  7.  
  8. static struct osd_bitmap *tmpbitmap2;
  9. static unsigned char *dirtybuffer2;
  10. static int flipscreen;
  11.  
  12.  
  13.  
  14. /***************************************************************************
  15.  
  16.   Start the video hardware emulation.
  17.  
  18. ***************************************************************************/
  19. int solomon_vh_start(void)
  20. {
  21.     int i;
  22.  
  23.  
  24.     if (generic_vh_start() != 0)
  25.         return 1;
  26.  
  27.     if ((tmpbitmap2 = osd_create_bitmap(Machine->drv->screen_width,Machine->drv->screen_height)) == 0)
  28.     {
  29.         generic_vh_stop();
  30.         return 1;
  31.     }
  32.  
  33.     if ((dirtybuffer2 = malloc(videoram_size)) == 0)
  34.     {
  35.         osd_free_bitmap(tmpbitmap2);
  36.         generic_vh_stop();
  37.         return 1;
  38.     }
  39.     memset(dirtybuffer2,1,videoram_size);
  40.  
  41.     /* leave everything at the default, but map all foreground 0 pens as transparent */
  42.     for (i = 0;i < 8;i++) palette_used_colors[16 * i] = PALETTE_COLOR_TRANSPARENT;
  43.  
  44.     return 0;
  45. }
  46.  
  47.  
  48.  
  49. /***************************************************************************
  50.  
  51.   Stop the video hardware emulation.
  52.  
  53. ***************************************************************************/
  54. void solomon_vh_stop(void)
  55. {
  56.     osd_free_bitmap(tmpbitmap2);
  57.     free(dirtybuffer2);
  58.     generic_vh_stop();
  59. }
  60.  
  61.  
  62. WRITE_HANDLER( solomon_bgvideoram_w )
  63. {
  64.     if (solomon_bgvideoram[offset] != data)
  65.     {
  66.         dirtybuffer2[offset] = 1;
  67.  
  68.         solomon_bgvideoram[offset] = data;
  69.     }
  70. }
  71.  
  72. WRITE_HANDLER( solomon_bgcolorram_w )
  73. {
  74.     if (solomon_bgcolorram[offset] != data)
  75.     {
  76.         dirtybuffer2[offset] = 1;
  77.  
  78.         solomon_bgcolorram[offset] = data;
  79.     }
  80. }
  81.  
  82.  
  83.  
  84. WRITE_HANDLER( solomon_flipscreen_w )
  85. {
  86.     if (flipscreen != (data & 1))
  87.     {
  88.         flipscreen = data & 1;
  89.         memset(dirtybuffer,1,videoram_size);
  90.         memset(dirtybuffer2,1,videoram_size);
  91.     }
  92. }
  93.  
  94.  
  95.  
  96. /***************************************************************************
  97.  
  98.   Draw the game screen in the given osd_bitmap.
  99.   Do NOT call osd_update_display() from this function, it will be called by
  100.   the main emulation engine.
  101.  
  102. ***************************************************************************/
  103. void solomon_vh_screenrefresh(struct osd_bitmap *bitmap,int full_refresh)
  104. {
  105.     int offs;
  106.  
  107.  
  108.     /* recalc the palette if necessary */
  109.     if (palette_recalc())
  110.     {
  111.         memset(dirtybuffer,1,videoram_size);
  112.         memset(dirtybuffer2,1,videoram_size);
  113.     }
  114.  
  115.  
  116.     for (offs = 0;offs < videoram_size;offs++)
  117.     {
  118.         if (dirtybuffer2[offs])
  119.         {
  120.             int sx,sy,flipx,flipy;
  121.  
  122.  
  123.             dirtybuffer2[offs] = 0;
  124.             sx = offs % 32;
  125.             sy = offs / 32;
  126.             flipx = solomon_bgcolorram[offs] & 0x80;
  127.             flipy = solomon_bgcolorram[offs] & 0x08;
  128.             if (flipscreen)
  129.             {
  130.                 sx = 31 - sx;
  131.                 sy = 31 - sy;
  132.                 flipx = !flipx;
  133.                 flipy = !flipy;
  134.             }
  135.  
  136.             drawgfx(tmpbitmap2,Machine->gfx[1],
  137.                     solomon_bgvideoram[offs] + 256 * (solomon_bgcolorram[offs] & 0x07),
  138.                     ((solomon_bgcolorram[offs] & 0x70) >> 4),
  139.                     flipx,flipy,
  140.                     8*sx,8*sy,
  141.                     0,TRANSPARENCY_NONE,0);
  142.         }
  143.     }
  144.  
  145.     /* copy the character mapped graphics */
  146.     copybitmap(bitmap,tmpbitmap2,0,0,0,0,&Machine->drv->visible_area,TRANSPARENCY_NONE,0);
  147.  
  148.     /* draw the frontmost playfield */
  149.     for (offs = videoram_size - 1;offs >= 0;offs--)
  150.     {
  151.         if (dirtybuffer[offs])
  152.         {
  153.             int sx,sy;
  154.  
  155.  
  156.             dirtybuffer[offs] = 0;
  157.             sx = offs % 32;
  158.             sy = offs / 32;
  159.             if (flipscreen)
  160.             {
  161.                 sx = 31 - sx;
  162.                 sy = 31 - sy;
  163.             }
  164.  
  165.             drawgfx(tmpbitmap,Machine->gfx[0],
  166.                     videoram[offs] + 256 * (colorram[offs] & 0x07),
  167.                     (colorram[offs] & 0x70) >> 4,
  168.                     flipscreen,flipscreen,
  169.                     8*sx,8*sy,
  170.                     &Machine->drv->visible_area,TRANSPARENCY_NONE,0);
  171.         }
  172.     }
  173.  
  174.     copybitmap(bitmap,tmpbitmap,0,0,0,0,&Machine->drv->visible_area,TRANSPARENCY_PEN,palette_transparent_pen);
  175.  
  176.  
  177.     /* draw sprites */
  178.     for (offs = spriteram_size - 4;offs >= 0;offs -= 4)
  179.     {
  180.         int sx,sy,flipx,flipy;
  181.  
  182.  
  183.         sx = spriteram[offs+3];
  184.         sy = 241-spriteram[offs+2];
  185.         flipx = spriteram[offs+1] & 0x40;
  186.         flipy =    spriteram[offs+1] & 0x80;
  187.         if (flipscreen & 1)
  188.         {
  189.             sx = 240 - sx;
  190.             sy = 240 - sy;
  191.             flipx = !flipx;
  192.             flipy = !flipy;
  193.         }
  194.  
  195.         drawgfx(bitmap,Machine->gfx[2],
  196.                 spriteram[offs] + 16*(spriteram[offs+1] & 0x10),
  197.                 (spriteram[offs + 1] & 0x0e) >> 1,
  198.                 flipx,flipy,
  199.                 sx,sy,
  200.                 &Machine->drv->visible_area,TRANSPARENCY_PEN,0);
  201.     }
  202. }
  203.